﻿
var	userCardURI='http://t.qq.com/asyn/userCard.php',
	isQuering=false,uid;
entryJS();
function entryJS(){
	var followingURI=/http\:\/\/t\.qq\.com\/\w+\/(following|follower)(\?p=\d*)*/g;
	if($('LUI')!=null){
		uid=$$('.link')[0].href.replace(/http\:\/\/t\.qq\.com\//g,'');
		getUserCard(uid,'single');
	}else if(followingURI.exec(window.location.href)){
		var i=0,u;
		UI.each($$('.msgBox'),function(e){
			getUserCard(getUid(UI.GT(e,'a')[0].title),'list',e);
		});
	}
}
//Show user's card
function getUserCard(user,t,o){
	UI.get(userCardURI,'u='+user,function(e){
		e=MI.json(e);
		var isfo=e.info.followed,html=UI.DC('span'),gender=e.info.gender;
		html.innerHTML=isfo?'[已收听我]':'[未收听我]';
		if(t=='single'){
			html.style.cssText='margin:1em;color:'+(isfo==1?'green':'red')+';font-weight:bold;';
			if($('followTxt').style.display!='none')
				UI.append(html,$('followTxt'));
			else
				UI.after(html,UI.next($('followTxt')));
		}else if(t=='list'){
			if(!isfo)UI.parent(o).style.background='yellow';
			html.style.cssText='color:#999;';
			var uri=window.location.href;
			if(uri.indexOf('following')!=-1 && uri.indexOf('follower')==-1)
				UI.append(html,UI.children(o,'userNums')[0]);
			UI.children(o,'userNums')[0].style.cssText='white-space:nowrap;';
			UI.GT(UI.children(o)[0],'a')[0].style.color=gender?'#3333ff':'#ff66cc';
		}
	});
}//getUserCard(MI.user.account);
function getUid(ustr){
	return ustr.replace(/.+\(@(.+)\)/g,"$1");
}